FROM golang:alpine as builder

ENV APP_DIR=/go/src
ENV GO111MODULE=on
ENV GOPROXY="https://goproxy.cn,https://goproxy.io,direct"

COPY . ${APP_DIR}
WORKDIR ${APP_DIR}

RUN go mod tidy && go build -o WebMqttPusher


FROM alpine

COPY --from=builder /go/src/WebMqttPusher /usr/local/bin/WebMqttPusher
COPY run.sh .

ENV addr="0.0.0.0:80"
ENV broker=""
ENV username=""
ENV password=""

EXPOSE 80

ENTRYPOINT [ "sh", "./run.sh" ]
# docker run -d -p 8088:80 --name webmqttpusher -e broker="yourmqttbroker.com:1883" WebMqttPusher